﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PMisuseAn
{
    [Serializable()]
    public class Actor
    {
        private string name_;
        private string clusterName_;
        private List<Attribute> attributes_;
        private List<string> roles_;

        public Actor()
        {
            attributes_ = new List<Attribute>();
            roles_ = new List<string>();
        }

        public string clusterName
        {
            get
            {
                return clusterName_;
            }
            set
            {
                clusterName_ = value;
            }
        }

        public string name
        {
            get
            {
                return name_;
            }
            set
            {
                name_ = value;
            }
        }
        public List<Attribute> attributes
        {
            get
            {
                return attributes_;
            }
        }
        public void addAttribute(Attribute att)
        {
            bool exist = false;
            foreach (Attribute attx in attributes_)
            {
                if (attx.name.Equals(att.name))
                {
                    exist = true;
                    break;
                }
            }
            if (exist == false)
            {
                attributes_.Add(att);

            }

        }
        public void setAttributes(List<Attribute> attributes)
        {
            attributes_ = attributes;
        }
                
        public List<string> roles
        {
            get
            {
                return roles_;
            }
        }
        public void addRole(string role)
        {
            bool exist = false;
            foreach (string r in roles_)
            {
                if (r.Equals(role))
                {
                    exist = true;
                    break;
                }
            }
            if (exist == false)
            {
                roles_.Add(role);
            }
        }

        public void removeRole(string role)
        {
            foreach (string r in roles_)
            {
                if (r.Equals(role))
                {
                    roles_.Remove(r);
                    break;
                }
            }

        }
        public void setRoles(List<string> roles)
        {
            roles_ = roles;
        }
    }
}
